package lambda;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-04-02
 * Time: 13:49
 */
interface voidZero{
    void test();
}
interface voidOne{
    void test(int x);
}
interface voidTwo{
    void test(int x,int y);
}
interface intZero{
    int test();
}
interface intOne{
    int test(int x);
}
interface intTwo{
    int test(int x,int y);
}

public class Test1 {
    public static void main(String[] args) {
        //
        voidZero voidzero = () -> System.out.println("无返回值没有参数:    null");
        voidzero.test();
        //
        voidOne voidone = (int x) -> System.out.println("无返回值一个参数:    " + x);
        voidone.test(5);
        //
        voidTwo voidtwo = (int x,int y) -> System.out.println("无返回值两个参数:    " + (x + y));
        voidtwo.test(5,5);
        //
        intZero intzero = () -> 0;
        System.out.println("一个返回值没有参数:    " + intzero.test());
        //
        intOne intone = (int x) -> x;
        System.out.println("一个返回值一个参数:    " + intone.test(5));
        //
        intTwo inttwo = (int x,int y) -> x - y;
        System.out.println("一个返回值两个参数:    " + inttwo.test(10,5));

    }
}
class Test2{
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("C");
        list.add("B");
        list.add("A");
        System.out.print("排序前 = ");
        list.forEach((String s) -> System.out.print(s + " "));
        System.out.println();
        list.sort((String s1,String s2) -> s1.compareTo(s2));
        System.out.print("排序后 = ");
        list.forEach((String s) -> System.out.print(s + " "));
    }
}
class Test3{
    public static void main(String[] args) {
        Map<String,Integer> hashMap = new HashMap<>();
        hashMap.put("C",3);
        hashMap.put("B",2);
        hashMap.put("A",1);
        hashMap.forEach((String string,Integer integer) ->
                System.out.println("key = " + string + "," + "value = " + integer));
    }
}
